[Improvement-17960][API]Add null/empty/duplicate validation logic for globalParams when creating or updating a workflow#17961
Conversation
| try { | ||
| validateGlobalParams(globalParams); | ||
| } catch (ServiceException ex) { | ||
| log.warn("Invalid globalParams: {}", ex.getMessage()); | ||
| putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, ex.getMessage()); | ||
| return result; | ||
| } |
There was a problem hiding this comment.
| try { | |
| validateGlobalParams(globalParams); | |
| } catch (ServiceException ex) { | |
| log.warn("Invalid globalParams: {}", ex.getMessage()); | |
| putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, ex.getMessage()); | |
| return result; | |
| } | |
| validateGlobalParams(globalParams); |
Directly throw ServiceException at validateGlobalParams, please don't use a lot of try catch here.
There was a problem hiding this comment.
Suggested change
try {
validateGlobalParams(globalParams);
} catch (ServiceException ex) {
log.warn("Invalid globalParams: {}", ex.getMessage());
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, ex.getMessage());
return result;
}
validateGlobalParams(globalParams);
Directly throwServiceExceptionatvalidateGlobalParams, please don't use a lot of try catch here.
ok
| if (Direct.IN.equals(p.getDirect()) && StringUtils.isEmpty(p.getValue())) { | ||
| throw new ServiceException("IN param value required for key: " + key); | ||
| } |
There was a problem hiding this comment.
We should support the value to be null.
| /** | ||
| * Validates global parameters: non-empty keys, no duplicates, and required values for IN-type params. | ||
| */ | ||
| private void validateGlobalParams(String globalParams) { |
There was a problem hiding this comment.
We shouldn't be writing this kind of glue code everywhere. Why not use a GlobalParamValidator to handle this task?
# Conflicts: # dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java
Purpose of the pull request
close #17960
Brief change log
Add null/empty/duplicate validation logic for globalParams when creating or updating a workflow
Verify this pull request
This pull request is code cleanup without any test coverage.
(or)
This pull request is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(or)
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md